import request from '@/utils/request'

// 查询订单管理列表
export function listOrder(query) {
  return request({
    url: '/fiscale/order/list',
    method: 'get',
    params: query
  })
}

// 查询订单管理详细
export function getOrder(orderId) {
  return request({
    url: '/fiscale/order/' + orderId,
    method: 'get'
  })
}

// 新增订单管理
export function addOrder(data) {
  return request({
    url: '/fiscale/order',
    method: 'post',
    data: data
  })
}

// 修改订单管理
export function updateOrder(data) {
  return request({
    url: '/fiscale/order',
    method: 'put',
    data: data
  })
}

// 删除订单管理
export function delOrder(orderId) {
  return request({
    url: '/fiscale/order/' + orderId,
    method: 'delete'
  })
}

// 根据订单号查询订单
export function getOrderByOrderNo(orderNo) {
  return request({
    url: '/fiscale/order/getByOrderNo/' + orderNo,
    method: 'get'
  })
}

// 根据平台订单号查询订单
export function getOrderByPlatformOrderNo(platformOrderNo) {
  return request({
    url: '/fiscale/order/getByPlatformOrderNo/' + platformOrderNo,
    method: 'get'
  })
}

// 批量更新订单状态
export function batchUpdateOrderStatus(data) {
  return request({
    url: '/fiscale/order/batchUpdateStatus',
    method: 'put',
    data: data
  })
}

// 批量更新报关状态
export function batchUpdateCustomsStatus(data) {
  return request({
    url: '/fiscale/order/batchUpdateCustomsStatus',
    method: 'put',
    data: data
  })
}

// 生成报关单
export function generateCustoms(data) {
  return request({
    url: '/fiscale/order/generateCustoms',
    method: 'post',
    data: data
  })
}

// 同步平台订单
export function syncPlatformOrders(platformType, platformConfigId) {
  return request({
    url: '/fiscale/order/syncPlatformOrders',
    method: 'post',
    params: {
      platformType: platformType,
      platformConfigId: platformConfigId
    }
  })
}

// 获取订单统计信息
export function getOrderStatistics() {
  return request({
    url: '/fiscale/order/statistics',
    method: 'get'
  })
}

// 校验订单号是否唯一
export function checkOrderNoUnique(orderNo, orderId) {
  return request({
    url: '/fiscale/order/checkOrderNoUnique',
    method: 'get',
    params: {
      orderNo: orderNo,
      orderId: orderId
    }
  })
}